package com.smz.controller;

import com.smz.entity.RoleFun;
import com.smz.service.RoleFunService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class RoleFunctionsController {


    @Autowired
    private RoleFunService roleFunService;

    @PostMapping("/role-function")
    public ResponseEntity<String> addRoleFunctions(@RequestBody RoleFun roleFun){
        String s = roleFunService.addRoleFunction(roleFun);
        return ResponseEntity.ok(s);
    }

    @DeleteMapping("/role-function/{roleId}/{functionId}")
    public ResponseEntity<String> removeRoleFunction(@PathVariable("roleId")String roleId,
                                                     @PathVariable("functionId")String functionId){
        String str = roleFunService.removeRoleFunction(new RoleFun(0,roleId,functionId));
        return ResponseEntity.ok(str);
    }

}
